package main

import (
	"log"
	"net/http"

	"github.com/go-chi/chi/v5"
)

func homeHandler(w http.ResponseWriter, r *http.Request) {
	w.Header().Set("Content-Type", "text/html; charset=utf-8")
	w.Write([]byte(`<h1>Welcome to my site</h1>
	<form action="/contact">
	<button>
	Contacts
	</button>
	</form>
	`))
}

func contactHandler(w http.ResponseWriter, r *http.Request)  {
	w.Header().Set("Content-Type",  "text/html; charset=utf-8")
	w.Write([]byte(`<h1>Contact</h1>
	<form>
	<input type="text" name="name" placeholder="Name" />
	<input type="email" name="email" placeholder="Email"  />
	<textarea name="message" placeholder="Message"></textarea>
	<input type="submit" value="Send"/>
	</form>
	<form method="get" action="/">
	<button >
	Home
    </button>
	</form>
	`))
}

func main()  {
	r := chi.NewRouter()
	r.Get("/", homeHandler)
	r.Get("/contact", contactHandler)

	if err := http.ListenAndServe(
		":8080",
		r,
	); err != nil {
		log.Fatalf("Error: %s", err)
	}
}
